
//DYL
function ajaxRequest(url, method, data, successCallback) {
       // 获取token
       const token = localStorage.getItem('token');
       //ajax全局参数设置
       $.ajaxSetup({
           headers:{
               Authorization: 'Bearer '+token
           },
           // 发送cookie
           xhrFields: {
               withCredentials: true
           }
       });  
  if(method=='POST'){
    $.post({
      url:url,
      data: data,
      dataType: "json",
      timeout:300000,
      contentType: "application/json;charset=UTF-8",
      xhrFields:{withCredentials: true},
      success: function (res) {
        successCallback(res);
      },
      error: function (ero) {
        console.log(ero)
        console.log('post请求错误')
        errorCallback()
      }
    });
  }else if(method==='GET'){
    $.get({
      url: url,
      dataType: "json",
      timeout:300000,
      xhrFields:{withCredentials: true},
      data: data,
      success: function (res) {
        successCallback(res);
      },
      error: function (ero) {
        console.log(ero)
        console.log('请求错误')
        errorCallback()
      }
   });
  }
}
  
  
  